<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>约健</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">

    {include file="public:headfile"}
</head>

<body class="hold-transition sidebar-mini">
<div class="wrapper">

    {include file="public:head"}

    {include file="public:slidemenu"}

    <div class="content-wrapper">

        <section class="content-header">
            <div class="container-fluid">
                <div class="row mb-2">
                    <div class="col-sm-6">
                        <h1>Data Tables</h1>
                    </div>
                </div>
            </div>
        </section>



        <!-- Main content -->
        <section class="content">
            <div class="row">
                <div class="col-12">
                    <div class="card">
                        <div class="card-header">
                            <h3 class="card-title">教练列表</h3>
                            <button data-toggle="modal"
                                    data-target="#add">
                                添加
                            </button>
                        </div>
                        <!-- /.card-header -->
                        <div class="card-body">
                            <table id="example2" class="table table-bordered table-hover">
                                <thead>
                                <tr>
                                    <th>编号</th>
                                    <th>教练名</th>
                                    <th>教练照片</th>
                                    <th>联系电话</th>
                                    <th>简介</th>
                                    <th>操作</th>
                                </tr>
                                </thead>
                                <tbody>
                                {volist name="list" id="vo"}
                                <tr>
                                    <td>{$vo.tid}</td>
                                    <td>{$vo.tname}</td>
                                    <td><img src="__STATIC__/img/trainers/{$vo.tpic} " style="width: 70px;height:70px"></td>
                                    <td>{$vo.ttel}</td>
                                    <td>{$vo.tintro}</td>
                                    <td>
                                        <button data-toggle="modal"
                                                data-target="#update" data-tid="{$vo.tid}" onclick="jsedit(this)">
                                            修改
                                            </button>
                                        <button>
                                            <a style="color: black" href="{:url('ClubAdmin/TrainersController/delete',['id'=>$vo.tid])}">
                                                删除
                                            </a>
                                        </button>
                                    </td>
                                </tr>
                                {/volist}
                                </tbody>
                            </table>
                        </div>
                        {$list->render()}
                        <!-- /.card-body -->
                    </div>
                    <!-- /.card -->
                </div>
                <!-- /.col -->
            </div>
            <!-- /.row -->
        </section>
        <!-- /.content -->

    </div>
</div>
<div class="modal fade" id="add" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <h4 class="modal-title" id="myModalLabel">添加教练</h4>
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
            </div>
            <form class="form-horizontal" action="{:url('ClubAdmin/TrainersController/add')}" method="post" enctype="multipart/form-data">
                <div class="form-group">
                    <label for="Tname" class="col-md-2 control-label">教练名</label>
                    <div class="col-md-6">
                        <input type="text" class="form-control" id="Tname" placeholder="教练名" name="tname">
                    </div>
                </div>
                <div class="form-group">
                    <label for="Tpic" class="col-md-2 control-label">照片</label>
                    <div class="col-md-6">
                        <input type="file" id=Tpic name="tpic">
                    </div>
                </div>

                <div class="form-group">
                    <label for="Ttel" class="col-md-2 control-label">电话</label>
                    <div class="col-md-6">
                        <input type="text" class="form-control" id="ttel" placeholder="电话" name="ttel">
                    </div>
                </div>

                <div class="form-group">
                    <label for="Tintro" class="col-md-2 control-label">简介</label>
                    <div class="col-md-6">
                        <input type="text" class="form-control" id="Tintro" placeholder="简介" name="tintro">
                    </div>
                </div>


                <div class="form-group">
                    <div class="col-md-offset-2 col-md-10">
                        <input type="submit" name="" value="提交" class="btn btn-default">
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>

<div class="modal fade" id="update" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <h4 class="modal-title" id="myModalLabel2">修改教练</h4>
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
            </div>
            <form class="form-horizontal" action="{:url('ClubAdmin/TrainersController/update')}" method="post" enctype="multipart/form-data">
                <div class="form-group">
                    <label for="Tname1" class="col-md-2 control-label">教练名</label>
                    <div class="col-md-6">
                        <input type="text" class="form-control" id="tname1" placeholder="教练名" name="tname1">
                    </div>
                </div>
                <div class="form-group">
                    <label for="Tpic1" class="col-md-2 control-label">照片</label>
                    <div class="col-md-6">
                        <input type="file" id=Tpic1 name="tpic1">
                    </div>
                </div>

                <div class="form-group">
                    <label for="Ttel1" class="col-md-2 control-label">电话</label>
                    <div class="col-md-6">
                        <input type="text" class="form-control" id="ttel1" placeholder="电话" name="ttel1">
                    </div>
                </div>

                <div class="form-group">
                    <label for="Tintro1" class="col-md-2 control-label">简介</label>
                    <div class="col-md-6">
                        <input type="text" class="form-control" id="Tintro1" placeholder="简介" name="tintro1">
                    </div>
                </div>

                <input type="hidden" name="tid" value="" id="hidden" >


                <div class="form-group">
                    <div class="col-md-offset-2 col-md-10">
                        <input type="submit" name="" value="提交" class="btn btn-default">
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>

<script type="text/javascript">
    function jsedit(that)
    {
        var tid=$(that).attr('data-tid');
        $.ajax({
            url:"{:url('TrainersController/show')}",
            data:{
                "tid":tid
            },
            dataType:'json',
            success(data){
                console.log(data);
                $("#tname1").val(data.tname);
                //
                $("#ttel1").val(data.ttel);
                //
                $("#Tintro1").val(data.tintro);
                //
                // $("#tel").val(data.utel);

                $("#hidden").val(data.tid);
                //
                // $("#edit").modal.show;

            }
        });
    }

</script>
                {include file="public:footfile"}

</body>

</html>